package Frame;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JDialog;
import javax.swing.JPanel;

import Function.FCAnimationLibrary;

@SuppressWarnings("serial")
public class FCTableAnimation extends JDialog {
	public FCTableAnimation(FCAnimationLibrary anil, Image im) {
		setBounds(0, 0, 1000, 600);
		setLayout(null);
		setLocationRelativeTo(null);
		setIconImage(im);
		// setResizable(false);
		setModal(true);
		setTitle("查看攻击动画");

		JPanel t = new JPanel() {
			private Color c1 = new Color(220, 220, 220);
			private Font f1 = new Font("黑体", 0, 15);
			private Font f2 = new Font("黑体", 0, 13);

			@Override
			protected void paintComponent(Graphics g) {
				// 表头
				g.setColor(c1);
				g.fillRect(0, 0, getWidth(), 16);
				g.setColor(Color.black);
				g.setFont(f1);
				g.drawString("ID", 10, 14);
				g.drawString("描述", 210, 14);
				g.drawLine(200, 0, 200, 16);
				g.drawLine(0, 16, getWidth(), 16);
				g.setFont(f2);
				for (int i = 0; i < anil.getAnimationNum(); i++) {
					g.drawString(anil.getIDOfNum(i), 5, 30 + 16 * i);
					g.drawString(anil.getInfoOfNum(i), 210, 30 + 16 * i);
					g.drawLine(0, 32 + 16 * i, getWidth(), 32 + 16 * i);
					g.drawLine(200, 16 + 16 * i, 200, 32 + 16 * i);
				}
			}
		};
		t.setBounds(0, 0, getWidth(), getHeight());
		this.add(t);
		addComponentListener(new ComponentListener() {
			@Override
			public void componentShown(ComponentEvent arg0) {
			}

			@Override
			public void componentResized(ComponentEvent arg0) {
				t.setBounds(0, 0, getWidth(), getHeight());
				t.updateUI();
			}

			@Override
			public void componentMoved(ComponentEvent arg0) {
			}

			@Override
			public void componentHidden(ComponentEvent arg0) {
			}
		});

		setVisible(true);
	}
}
